package com.dragon.repository.domain.vo;

import com.dragon.common.model.Update;
import com.dragon.repository.entity.InoutProduct;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import com.dragon.common.util.BeanUtils;

import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import java.util.ArrayList;
import java.util.List;
import java.util.Date;


/**
 * @author sy
 */
@Data
@ApiModel(value = "")
public class InoutProductVO {

    private static final long serialVersionUID = 1L;

    private Integer id;

    @ApiModelProperty(value = "出入库id")
    private Integer inoutId;

    @ApiModelProperty(value = "领用商品id")
    private Integer claimsProductId;

    @ApiModelProperty(value = "初始数量")
    private Double inceptionNum;

    @ApiModelProperty(value = "预估出入数量")
    private Double inoutNum;

    @ApiModelProperty(value = "最终数量")
    private Double finallyNum;

    @ApiModelProperty(value = "实际数量")
    private Double actualNum;

    @ApiModelProperty(value = "单位id")
    private Integer unitId;

    @ApiModelProperty(value = "规格名称")
    private String specificationName;

    @ApiModelProperty(value = "商品spu名称")
    private String productSpuName;

    @ApiModelProperty(value = "单位名称")
    private String unitName;


    @NotNull(groups = Update.class,message = "主键不能为空")
    public static InoutProduct convert(InoutProductVO vo) {
        InoutProduct entity = new InoutProduct();
        BeanUtils.copyProperties(vo,entity);
        return entity;
    }
    public static List<InoutProduct> convertList(List<InoutProductVO> list) {
        List<InoutProduct> resultList = new ArrayList<>();
        for (InoutProductVO vo : list) {
            resultList.add(convert(vo));
        }
        return resultList;
    }
}
